package exam.zijie;

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.concurrent.ThreadPoolExecutor;

public class test1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] word = scanner.next().split(",");
        int num = word[0].length();
        int son = Integer.parseInt(word[1]);
        Set<Character> set = new HashSet<Character>();
        int flag = 0;
        for(int i = 0;i<num;i++){
            if(!set.add( word[0].charAt(i))){
                System.out.print(0);
                flag = 1;
            }
        }
        int res = 0;
        if(flag==0){
            if(son<=0||son>52||son>num){
                System.out.print(0);
            }else{
                res = num;
                num--;
                for(int i = 2;i<=son;i++){
                    res = res*num/i;
                    num--;
                }
                System.out.print(res);
            }

        }
    }
}
